/**
 * Copyright &copy; 2016-2017 <a href="https://www.lczyfz.com">联创智云</a> All rights reserved.
 */
package com.lczyfz.campusinfo.modules.jobmesmanage.web;
import com.lczyfz.campusinfo.common.utils.ApiResultUtils;
import com.lczyfz.campusinfo.common.utils.StringUtils;
import com.lczyfz.campusinfo.common.web.BaseController;
import com.lczyfz.campusinfo.modules.creatjobmanage.entity.CreatJobProject;
import com.lczyfz.campusinfo.modules.creatjobmanage.entity.CreatPartProject;
import com.lczyfz.campusinfo.modules.creatjobmanage.service.CreatJobProjectService;
import com.lczyfz.campusinfo.modules.creatjobmanage.service.CreatPartProjectService;
import com.lczyfz.campusinfo.modules.jobmesmanage.entity.JobMesSearch;
import com.lczyfz.campusinfo.modules.jobmesmanage.entity.StuJobSearch;
import com.lczyfz.campusinfo.modules.jobmesmanage.service.JobMesSearchService;
import com.lczyfz.campusinfo.modules.jobmesmanage.service.StuJobSearchService;
import com.lczyfz.campusinfo.modules.sys.security.SystemAuthorizingRealm;
import com.lczyfz.campusinfo.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import java.util.List;

/**
 * 勤工视图Controller
 * @author zms
 * @version 2018-04-01
 */
@Controller
@RequestMapping(value = "/api/schoolSource/enlist")
public class StuJobApiSearchController extends BaseController {

	@Autowired
	private StuJobSearchService stuJobSearchService;
	@Autowired
	private JobMesSearchService jobMesSearchService;
	@Autowired
	private CreatJobProjectService creatJobProjectService;
	@Autowired
	private CreatPartProjectService creatPartProjectService;

	@RequestMapping(value = "jobList" ,method = RequestMethod.POST)
	@ResponseBody    //获取报名信息
	public Map<String, Object> getNotice( HttpServletRequest request, HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> map = ApiResultUtils.getBaseMapSuccess();
		SystemAuthorizingRealm.Principal principal = UserUtils.getPrincipal(); //判断用户是否掉线
		if (principal!=null) {
			StuJobSearch stuJobSearch = new StuJobSearch();
			JobMesSearch jobMesSearch = new JobMesSearch();
			stuJobSearch.setUserId(principal.toString());
			jobMesSearch.setUserId(principal.toString());
			CreatJobProject creatJobProject = new CreatJobProject();
			creatJobProject.setUpId(principal.toString());
			CreatPartProject creatPartProject = new CreatPartProject();
			creatPartProject.setUpId(principal.toString());
			List<StuJobSearch> stuJobSearches = stuJobSearchService.findList(stuJobSearch);
			List<JobMesSearch> jobMesSearches = jobMesSearchService.findList(jobMesSearch);
			List<CreatJobProject> creatJobProjects = creatJobProjectService.findList(creatJobProject);
			List<CreatPartProject> CreatPartProjects = creatPartProjectService.findList(creatPartProject);
			map.put("stuJobSearches", stuJobSearches);
			map.put("jobMesSearches", jobMesSearches);
			map.put("creatJobProjects", creatJobProjects);
			map.put("CreatPartProjects", CreatPartProjects);
			map.put("message",true);
			return map;
		} else {
			map.put("message",false); //没有用户的信息
		}
       return  map;
	}
}